﻿using System;

namespace Jodell.Transport.Ethercat
{
    public class SoemException : Exception
    {
        public SoemException(int erroCode)
        {
            this.ErrorCode = erroCode;

        }
        public int ErrorCode { get; private set; }

        public override string Message
        {
            get
            {
                string errorMsg = string.Empty;
                if (this.ErrorCode == ERROR_IF_INIT_ERROR)
                {
                    errorMsg = "网卡初始化失败！";
                }
                else if (this.ErrorCode == ERROR_SLAVE_NOT_FOUND)
                {
                    errorMsg = "未发现从站";
                }
                return errorMsg;
            }
        }
        public const int ERROR_IF_INIT_ERROR = 0x500;//网卡初始化失败
        public const int ERROR_SLAVE_NOT_FOUND = 0x501;//未发现从站
        public const int ERROR_STATE_CHANG_OP = 0x502;//切换OP失败
        public const int ERROR_SDO_TIMEOUT = 0x503;//SDO 通讯失败
        public const int ERROR_PDO_INDEX = 0x504;//PDO 索引错误
    }
}
